Saving to a file in C# [on hold]

Posted by user36322 on Game Development See other posts from Game Development or by user36322
Published on 2013-10-23T00:34:41Z Indexed on 2013/10/23 4:12 UTC
Read the original article Hit count: 162

Filed under:

If I use this code:

                        using (StreamWriter streamWriter = new StreamWriter("Content/player.txt", true))
                    {
                        streamWriter.Write("Hello!");
                        streamWriter.Close();
                    }

The program will not actually add "Hello!" to the file. However, if I use this code:

                        using (StreamWriter streamWriter = new StreamWriter("C:/Users/Michael/Documents/Visual Studio 2010/Projects/PuzzleGame/PuzzleGame/PuzzleGameContent/player.TXT", true))
                    {
                        streamWriter.Write("Hello!");
                        streamWriter.Close();
                    }

The program will work as intended and add "Hello!" to the save file. Is there any way I can do this without hardcoding the path?

© Game Development or respective owner

Related posts about c#